package main

import (
	"fmt"
	"encoding/json"
	"reflect"
)

type Student struct {
	Name string
	Age int
}

type Students struct {
	name string
	age int
}

func main() {

	structs1 := Student{Name:"wgc",Age:12}

	structs2 := Students{"wgc",12}


	//fmt.Printf("json string is %+v \n", structs1)

	jsonStr1, _ :=json.Marshal(structs1)

	jsonStr2, _ :=json.Marshal(structs2)


	//序列化json成功
	fmt.Printf("fomat json str is %v \n", string(jsonStr1))

	fmt.Printf("jsonStr1 type is %v \n", reflect.TypeOf(jsonStr1))
	//序列化json失败，私有属性无法序列化
	fmt.Printf("fomat json str is %v \n", string(jsonStr2))

	stus := &Student{}
	json.Unmarshal([] byte ("{\"Name\":\"wgc\",\"Age\":12}"), stus)

	fmt.Printf(" json deserealized is %+v" ,stus)
}
